var AllOptions = {
    createOption1(dataList) { //省内疫苗生产企业经济现状
        return {
            color: ['rgba(235, 52, 50, 1)', 'rgba(255, 151, 34, 1)', 'rgba(41, 161, 247, 1)', 'rgba(5, 209, 135, 1)', ],
            grid: {
                left: 0,
                top: 10,
                bottom: 20,
                right: 20
            },
            series: [{
                type: 'pie',
                radius: [20, 130],
                center: ['50%', '50%'],
                roseType: 'area',
                stillShowZeroSum: false,
                labelLine: {
                    length: 10,
                    length2: 10
                },
                label: {
                    normal: {
                        formatter: '{b} {c}%',
                        fontSize: 16,
                    }
                },
                data: dataList
            }]
        }
    },
    createOption2(mapCityJson, dataList) {
        echarts.registerMap('china', mapCityJson); 
        var geoCoordMap = {}
        for (var i = 0; i < mapCityJson.features.length; i++) {
            var name = mapCityJson.features[i].properties.name
            geoCoordMap[name] = mapCityJson.features[i].properties.center
        }         
        var formatData = {}//将地址名字和对应的数据转化为map对象
        for (var i = 0; i < dataList.length; i++) {
            var name = dataList[i][1].name
            formatData[name] = dataList[i][1].value
        }

        var convertData = function(data) {//给覆盖物层加入坐标
            var res = [];
            for (var i = 0; i < data.length; i++) {
                var dataItem = data[i];
                var fromCoord = geoCoordMap[dataItem[0].name];
                var toCoord = geoCoordMap[dataItem[1].name];
                if (fromCoord && toCoord) {
                    res.push({
                        fromName: dataItem[0].name,
                        toName: dataItem[1].name,
                        coords: [fromCoord, toCoord]
                    });
                }
            }
            return res;
        };
        var series = [{
            left: 150,
            right: 30,
            top: 20,
            bottom: 10,
            name: '',
            type: 'map',
            mapType: 'china', // 自定义扩展图表类型
            itemStyle: {
                normal: {
                    label: { show: true, color: '#fff' },
                    areaColor:'#002587',
                    borderWidth: 2,
                    borderColor: '#1548af',

                },
                emphasis: {
                    label: { show: true, color: '#fff' },
                    areaColor: '#0a0d49',
                    borderWidth: 3,
                    borderColor: '#1548af',
                }
            },
            data: mapCityJson.features.map(function(item){
                if(formatData[item.properties.name]){
                   return {name:item.properties.name,value:formatData[item.properties.name].ycfyfss*1,otherValue:formatData[item.properties.name]}
                }else{
                    return {name:item.properties.name,value:0,otherValue:{xl:0,ycfyfss:0,ycfyfsl:0}}
                }
            })

        }
        
        ];
        
        dataList.forEach(function(item, i) {
            series.push(
            {
                name: item[0].name,
                type: 'lines',
                zlevel: 2,
                symbol: ['none'],
                symbolSize: 10,
                effect: {
                    show: true,
                    period: 6,
                    trailLength: 0,
                    symbol: 'arrow', //planePath,
                    color: '#f0ff00',
                    symbolSize: 12
                },
                lineStyle: {
                    normal: {
                        color: '#f0ff00',
                        width: 1,
                        opacity: 0.6,
                        curveness: 0.2
                    }
                },
                data: convertData(dataList)
            }, 
            {
                name: item[0].name,
                type: 'effectScatter',
                coordinateSystem: 'geo',
                zlevel: 2,
                rippleEffect: {
                    brushType: 'stroke',
                    scale: 6,
                    period: 3,
                },
                // symbolSize:4,
                symbolSize: function(val) {
                    return val[1] / 8;
                },
                itemStyle: {
                    normal: {
                        color: 'rgba(248, 231, 28, 0.5)',
                        borderWidth:5,
                        borderColor:'rgba(248, 231, 28, 0.5)'
                    },
                    emphasis: {
                        color: 'rgba(248, 231, 28, 0.5)',
                        borderWidth:5,
                        borderColor:'rgba(248, 231, 28, 0.5)'
                    }
                },
                data: dataList.map(function(dataItem) {
                    return {
                        name: dataItem[1].name,
                        value:geoCoordMap[dataItem[1].name].concat([dataItem[1].value])
                    };
                })
            });
        });

        option = {
            visualMap: {
                type: 'continuous',
                orient: 'vertical',
                left: 30,
                bottom: 240,
                // min:0,
                // max:1000,
                align: 'bottom',
                text: ['高', '低'],
                dimension: 0,//制定第一个数据（value）
                calculable: true,
                seriesIndex:0,//重要，制定第一组数据作为关联项，不设置时波纹小圆圈的颜色会跟随这个颜色
                textStyle: {
                    color: 'rgba(56, 235, 249, 1)'
                },
                range: [0, 1000],
                formatter: '{value}',//对应数据中的value字段
                inRange: {
                    color: ['rgba(0,25,92,1)','rgba(27,109,255,1)']
                },
                outOfRange: {
                    color: ['#111']
                },
            },
            geo: {
                map: 'china',
                label: {
                    emphasis: {
                        show: false
                    }
                },
                aspectScale:0.75,
                roam: false,
                zoom:1.2,
                left: 217, top: 90, right: 96, bottom: 78,
                // layoutCenter: ['80%', '30%'],
                itemStyle: {
                    normal: {
                        areaColor: '#eee',
                        borderWidth:4,
                        borderColor: '#37e7f6',
                        shadowColor: 'rgba(56, 235, 249, 1)',
                        shadowBlur: 10
                    },
                    emphasis: {
                        areaColor: '#2a333d'
                    }
                }
            },
            series: series
        };
        return option
    }

}